home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-05 | 6.0 KB | 289 lines | [TEXT/MJUA] |
- {This macros show how to use Survival macro commands for AUTOMATED ANALYSIS
- The possibilities are only limited by your imagination. Remember that you
- may use all Pascal standard functions within a macro. Probably you may need
- some book on elemental Pascal programming to take the maximun advantage}
-
- MACRO 'TimeDependent';
-
- {This macro is to be used with Time-Dependent Analysis
- It must be the only macro or the FIRST macro in a multiple
- macro file. You may edit the code to adapt it to your needs.
- See also TIME MACRO 1 in the Macros folder}
-
- begin
-
- FUNCTION
- If rData[2] >= 650 then rVar[1]:= (rVar[1] - rMean[1]) else rVar[1]:= 0;
- rVar[2]:= (rVar[2] - rMean[2]); {Fixed covariate = grade}
- end;
- end;
-
-
-
- MACRO 'Macro_Time-Dependent_Analysis'
-
- begin
-
- RESET;
- GETDATA('HD516:Survival 6.0:Data:Data.surv');
- setStatus(1);
- setTime(2);
- selectVar(3,4);
- varcode(2,1);{Var 3 is time-dependent; var 4 is fixed}
- varLabel(3:'edad';4:'grado');
- covariates(80.5, 4);{we use this covariate pattern to estimate probability of survival}
- survplot('CoxModel');{Save the Model Plot}
- title('PROSTATE CANCER:TEN YEAR SURVIVAL ANALYSIS');
- backColor('white');
- estimate;{Time dependent analysis is TERMINATED here. Other commands are ignored}
- end;
-
- MACRO 'Kaplan-Meier'
-
- begin
-
- reset;
- getdata('Put here the path to access the file');
- stat(-);{compute descriptive statistics for all variables in data array}
- setStatus(1);
- setTime(2);
- survplot;{use always before the ESTIMATE command}
- backColor('white');
- setOutput('none');
- estimate;
- savepict('HD516:MyTest');{saves survival function}
- intplot(1);{use always AFTER the estimate command}
- savepict('HD516:Intervals');
- end;
-
-
- MACRO 'Macro_Strata'
-
- begin
-
- reset;
- getdata('Put here the path to access the file');
- setStatus(1);
- setTime(2);
- selectvar(4);
- setStrata(3, 5);{we have coded 3 groups in variable 5}
- grouplabel(1:'Stage A-B';2:'Stage C';3:'Stage D');{put label to indentify the groups}
- survplot;
- backColor('white');
- setOutput('none');
- estimate;
- savepict('strata');
- logplot;
- savepict('Log-Log');
- end;
-
-
- MACRO 'Macro_Test_1'{observe the result}
- var
- i: integer;
-
- begin
- reset;
- getdata('Put here the path to access the file');
- setStatus(1);
- setTime(2);
- survplot;
- setOutput('none');
- for i := 3 to 5 do
- begin
- selectVar(i);
- estimate;
- savepict('Test1');
- resplot;
- savepict('Residual1');{save residual plots and close}
- end;
- clear;{clears the active output window}
- RUNMACRO(3); {executes the Macro_Strata macro}
- RUNMACRO(7); {executes the Cut_Point macro}
- end;
-
- MACRO 'Macro_Test_2'{what is the difference respect to the macro above?}
- var
- i, row, column, nvar: integer;
-
- begin
- setStatus(1);
- setTime(2);
-
- reset;
- {getdata('Put here the path to access the file');}
- get(row, column, nvar);
- setStatus(1);
- setTime(2);
- survplot;
- setOutput('none');
- for i := 3 to 5 do
- begin
- set(row,column,0);{here is the key}
- selectVar(i);
- estimate;
- end;
- end;
-
- MACRO 'Macro_CutPoint'
-
- begin
-
- reset;
- {getdata('Put here the path to access the file');}
- setStatus(1);
- setTime(2);
- setCutPoint(70.5, 3);{cut point value (70.5) for variable in column 3}
- survplot;
- backColor('white');
- setOutput('basal');
- estimate;
- savepict('CutPoint');
- end;
-
- macro 'Macro_MakeBins'
-
- begin
-
- reset;
- getdata('Put here the path to access the file');
- setStatus(1);
- setTime(2);
- MakeBins(3, 3, true, 60, 70, 80);{we recode var 3 into 4 categories}
- setStrata(4,3);{stratified analysis}
- grouplabel(1:'<60 YEARS';2:'60-69 YEARS';3:'70-79 YEARS'; 4:'=>80 YEARS');{put label to
- indentify the groups}
- title('PROSTATE CANCER:STRATIFIED ANALYSIS BY AGE GROUPS');
- survplot;
- backColor('black');
- estimate;
- savepict('MakeBins');
- logplot;
- savepict('MakeBinsLog');
- revert; {Restores original data}
- end;
-
- MACRO 'Macro_Select'
-
- var
- edad,status,grado,stage:integer
-
- begin
- RESET;
- GETDATA('Put here the path to acces the file');
- SETSTATUS(1);
- SETTIME(2);
- SELECTIF((rData[4] = 2) and (rData[5] = 3));
- ESTIMATE;
- end;
-
- MACRO 'Macro_Omit_Compute'
-
- var
- status,time,grade:integer;
-
- begin
- reset;
- getdata('Put here the path to access the file');
- setStatus(1);
- setTime(2);
- OMITIF((rData[1] = 1) and (rData[2] < 180));
- COMPUTE
- rData[2] := rData[2] - 180;{what would happen if you omit this command ?}
- end;
- SELECTIF(rData[2] > 0);{just in case}
- backColor('white');
- estimate;
- end;
-
- MACRO 'Macro_Recode'
-
- var
- grado,stage:integer;
-
- begin
- grado:= 4;
- stage:= 5;
- reset;
- getdata('Put here the path to access the file');
- setStatus(1);
- setTime(2);
- recode(grado:1:2;stage:2:3:-9);
- MakeBins(3, 3, true, 60, 70, 80);
- end;
-
- MACRO 'Macro_Compute'
-
- var
- grado,stage,time:integer;
-
- begin
- time:= 2;
- grado:= 4;
- stage:= 5;
- reset;
- GETDATA('Put here the path to access the file');
- SETSTATUS(1);
- SETTIME(2);
- beep;
- COMPUTE
- {access to vars in data file with rDAta[]}
- {access to selected vars for current test with rVar[]}
- if (rDATA[4] = 2) and (rDATA[2] > 350) then rDATA[5]:= 9 else rDATA[5]:= -1;
- rData[6]:= -9;
- end;
- MAKEBINS(3, 3, true, 60, 70, 80);
- SETSTRATA(4,3);
- beep;
- ESTIMATE;
- end;
-
- MACRO 'Macro_Compute_Mean';
- var
- i,j,rows,cols,nvar,index:integer;
- Mean:real;
- begin
- get(rows,cols,nvar);{gets number of cases, variables and selected variables for the test, if any}
- for j:= 1 to cols do
- begin
- Mean:= 0;
- for i:= 0 to rows - 1 do
- begin
- index:= i * cols + j;
- Mean:= Mean + gData[index];{notice that we use gData[] instead of rData[]}
- end;
- Mean:= Mean/rows;
- Write('Mean of Variable ', 'with value',j,' is :',mean, ' for a total of', rows, ' variables');
- end;{For j}
- end;
-
- MACRO 'Macro_Compute_DS';
- var
- i,j,rows,cols,nvar,index:integer;
- sd,sigma1,sigma2:real;
- begin
- get(rows,cols,nvar);{gets number of cases, variables and selected variables for the test, if any}
- write('Standard Deviations are shown sequentially for variables 1 ..',cols);
- for j:= 1 to cols do
- begin
- sd:= 0;sigma1:= 0;sigma2:= 0;
- for i:= 0 to rows - 1 do
- begin
- index:= i * cols + j;
- sigma1:= Sigma1 + gData[index];
- sigma2:= sigma2 + sqr(gData[index]);
- end;
- sd:= sqrt((sigma2 - (sqr(sigma1)/rows))/(rows -1));
- Write('S.D. :',sd);
- end;{For j}
- end;
-
-
-
-
-
-
-
-
-
-